// Copyright (c) 2011 Vratislav Cermak (vratacermak@gmail.com)
//  
// This file is part of SrtSync Project. See http://code.google.com/p/srtsync/ for more information.
//  
// SrtSync is an open source project. Using of SrtSync is free of charge.
// It is distributed under GNU General Public License version 3 (GPLv3).
// GPLv3 can be found at http://www.gnu.org/licenses/gpl.html.
//  
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.

using System;
using System.Text;

namespace SrtSync.GtkProgram
{
	public delegate void ActivatedDelegate(object sender, EventArgs args);
	
	public static class MenuBuilder
	{
		public static Gtk.MenuItem AddTopMenuItem(this Gtk.MenuBar parent, Gtk.Menu subMenu, string name)
		{
			Gtk.MenuItem item = new Gtk.MenuItem(name) { Submenu = subMenu };
			parent.Add(item);
			return item;
        }
        
        public static Gtk.CheckMenuItem AddCheckMenuItem(this Gtk.Menu parent, string label)
        {
            Gtk.CheckMenuItem mi = new Gtk.CheckMenuItem(label);
            parent.Add(mi);
            return mi;
        }
		
		public static Gtk.MenuItem AddMenuItem(this Gtk.Menu parent, Gtk.Action action)
		{
			Gtk.MenuItem mi = (Gtk.MenuItem)action.CreateMenuItem();
			parent.Add(mi);
			return mi;
		}
		
		public static Gtk.MenuItem AddMenuItem(this Gtk.Menu parent, Encoding encoding)
		{
			Gtk.CheckMenuItem emi = new Gtk.CheckMenuItem(encoding.EncodingName);
			emi.Data.Add(typeof(Encoding), encoding);
			parent.Add(emi);
			return emi;
		}
		
		public static void AddSeparator(this Gtk.Menu parent)
		{
			parent.Add(new Gtk.SeparatorMenuItem());
		}
	}
}